<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	Long sysMills = System.currentTimeMillis();
	request.setAttribute("sysMills", sysMills);
%>
<!-- jQplot CSS -->
<link rel="stylesheet" media="screen" href="css/Tree.css" />
<!-- jQplot CSS END -->
<!-- DATATABLES CSS -->
<link rel="stylesheet" media="screen" href="lib/datatables/css/vpad.css" />
<table class="display" id="example">
	<thead>
		<tr>
			<th>培训课程</th>
			<th>开始日期</th>
			<th>结束日期</th>
			<th>培训对象</th>
			<th>培训类型</th>
			<th>状态</th>
			<th>讲师</th>
			<th>打印</th>
			<th>延期</th>
			<th>取消</th>
		</tr>
	</thead>
	<tbody>
		<s:if test="#request.plans==null || #request.plans.size<=0">
			<tr class="gradeA">
				<td colspan="10">暂无数据</td>
			</tr>
		</s:if>
		<s:else>
			<s:iterator var="plan" status="sta" value="#request.plans">
				<s:if test="#sta.even">
					<tr class="gradeA">
				</s:if>
				<s:else>
					<tr class="gradeC">
				</s:else>
				<td>${plan.title}</td>
				<td><fmt:formatDate value="${plan.planStartDate}"
						pattern="yyyy-MM-dd HH:mm" /></td>
				<td><fmt:formatDate value="${plan.planEndDate}"
						pattern="yyyy-MM-dd HH:mm" /></td>
				<td><span name="td_dutytarget" title="${plan.id}"></span></td>
				<td>${plan.category}</td>
				<td>
					<s:if test="#plan.cancel == 1">取消</s:if>
					<s:elseif test="#plan.amendReason != null">延期中</s:elseif>
					<s:elseif test="#plan.planStartDate.time > #request.sysMills">未开始</s:elseif>
					<s:elseif test="#plan.planStartDate.time <= #request.sysMills && #plan.planEndDate.time >= #request.sysMills">进行中</s:elseif>
					<s:else>已结束</s:else>
				</td>
				<td>${plan.trainLecturer.employeeinfoWork.baseId.name}</td>
				<s:if test="#plan.cancel == 1">
					<td colspan="3"></td>
				</s:if>
				<s:else>
					<td><a class="button" href="#train/plan_print_main.xhtml?planId=${plan.id}"><span
							style="background: url(${ctx}/images/img/printer.png)"
							class="icon icon-ok">&nbsp;</span>打印</a></td>
					<td><a class="button" href="#train/plan_delay_manage.xhtml?planId=${plan.id}"><span
							style="background: url(${ctx}/images/img/time_go.png)"
							class="icon icon-ok">&nbsp;</span>延期</a></td>
					<td><a class="button" href="#train/plan_cancel_manage.xhtml?planId=${plan.id}"><span
						style="background: url(${ctx}/images/img/cancel.png)"
						class="icon icon-ok">&nbsp;</span>取消</a></td>
				</s:else>
				</tr>
			</s:iterator>
		</s:else>
	</tbody>
</table>
<p>
	<%@ include file="/WEB-INF/pages/common/main_orgtab_pager_train.jsp"%>
</p>
<div class="clear"></div>

<script type="text/javascript">
	$(document).ready(function() {
		$("span[name='td_dutytarget']").each(function(i) {
			loadDutyTarget(this, $(this).attr("title"));
		});
	});

	function loadDutyTarget(obj, planId) {
		$.ajax({
			type : "get",
			url : "/ajax/query_dutytarget.xhtml?planId=" + planId,
			//data: "name=John&location=Boston",
			dataType : "html",
			success : function(data) {
				if (data != null) {
					$(obj).html(data);
				}
			}
		});
	}

	
</script>
